<template>
    <fieldset>
        <legend>子组件</legend>
        <h1>{{msg}}</h1>
        <h1 class="cl">来自父组件的:{{gift}}</h1>
        <button @click="handleClick">点击传给父组件</button>
    </fieldset>
</template>
<style scoped>
    .cl{
        color: green;
    }
</style>
<script>
    export default {
        data() {
            return {
                msg: "子组件的属性",
                toParent: "脑白金"
            }
        },
        // props:['gift'],
        props: {
            gift: {//属性校验
                type: String,//定义数据类型
                required:true,//是个必传属性
                default () {//定义默认值
                    return "默认值"
                }
            }
        },
        methods: {
            handleClick() {
                this.$emit("receive", this.toParent)
            }
        },
        mounted() {
            //注册一个接受兄弟组件参数的方法
            this.$bus.$on("getBro", (input) => {
                console.log(input);
            })
        }
    }
</script>